﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace KocKernelTest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        MainWindowViewModel _MWVM = null;

        public MainWindow()
        {
            InitializeComponent();

            _MWVM = new MainWindowViewModel();
            this.DataContext = _MWVM;

            this.kocServerActiveEditorControl1.InitDB(_MWVM.KRNL.EC.XMLDebugFilePath + "//AutoKoc.s3db");
            
            this.allianceList1.Initialize(_MWVM.KRNL);
            //this.allianceList1.AllianceClicked += new CSharp.Libs.WPF.UserControls.AllianceList.AllianceClickedEventHandler(allianceList1_AllianceClicked);

            this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing);

            //MessageBox.Show(
            //    CSharp.Libs.Koc.KocInfo.MapProvinceId.BodminMoor.ToString() + 
            //    " - " + 
            //    CSharp.Libs.Koc.KocInfo.MapProvinceId.BodminMoor.GetHashCode());
        }

        void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            this.comboBox1.Focus();
            //Changes in the DataGrid are saved to the OC
            //If staying on the DataGrid Row last edited, changes 
            //So the last change in the DataGrid inside kocServerActiveEditorControl1 gets 
            //saved
            this.kocServerActiveEditorControl1.SaveDB();
        }
    }
}
